generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

model Token {
  id            Int    @id @default(autoincrement())
  refresh_token String @unique
  user_id       Int

  user User @relation(fields: [user_id], references: [id])

  @@index([id])
  @@map("tokens")
}

model User {
  id           Int     @id @default(autoincrement())
  login        String  @unique
  email        String  @unique
  password     String
  is_activated Boolean @default(false)
  uuid         String  @unique

  tokens     Token[]
  userboards Userboards[]

  @@index([id])
  @@map("users")
}

model Userboards {
  id       Int @id @default(autoincrement())
  user_id  Int
  board_id Int

  user  User  @relation(fields: [user_id], references: [id])
  board Board @relation(fields: [board_id], references: [id])
}

model Board {
  id         Int    @id @default(autoincrement())
  title      String
  creator_id Int

  tasks      Task[]
  userboards Userboards[]

  @@index([id])
  @@map("boards")
}

model Task {
  id          Int      @id @default(autoincrement())
  board_id    Int
  creator_id  Int
  title       String
  description String
  status      String
  start_date  DateTime @default(now())
  final_date  DateTime

  board Board @relation(fields: [board_id], references: [id])

  @@index([id])
  @@map("tasks")
}
